package com.cmxh.mycloudnotes.Service;

import com.cmxh.mycloudnotes.mapper.ArticleMapper;
import com.cmxh.mycloudnotes.pojo.Article;
import com.cmxh.mycloudnotes.util.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleSetviceImpl implements ArticleService{

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public PageInfo<Article> findAll(PageUtil pageUtil) {
        //设置分页参数
        PageHelper.startPage(pageUtil.getPageNum(),pageUtil.getPageSize());
        //设置分页的参数
        Integer id = (Integer) pageUtil.getBenn();
        //第几条数据
        List<Article> list = articleMapper.findAll(id);

        // 记住 只要涉及到分页 后端给前端返回的就不是只有集合
        PageInfo <Article> pageInfo = new PageInfo<>(list);

        return pageInfo;

    }

    @Override
    public int pdateZt1(int id) {

        return articleMapper.pdateZt1( id );
    }

    @Override
    public List<Article> findAll(Integer id) {
        return articleMapper.findAll( id );
    }


}
